import {createRouter,createWebHashHistory} from 'vue-router'
const router = createRouter({
    history:createWebHashHistory(),
    routes:[
        {
            path:'/',
            // 重定向
            redirect:'/blogList'
        },
        {
            path:'/blogList',
            name:'blogList',
            meta:{title:'博客列表'},
            // 懒加载
            component:()=> import('../components/BodyList.vue')
        },
        {
            path:'/addBlog',
            name:'addBlog',
            meta:{title:'添加博客'},
            component:()=> import('../components/AddList.vue')
        }
    ]
})
router.beforeEach((to,from,next)=>{
    document.title = to.meta.title || 'Blog'
    next()
})
router.afterEach((to,from)=>{
    // console.log(to,from);
    document.title = to.meta.title || 'Blog'
})
export default router